// Color contrast
@function color-yiq($color) {
  $r: red($color);
  $g: green($color);
  $b: blue($color);

  $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
  $yiq-contrasted-threshold: 150; // 0 - 255

  @if ($yiq >= $yiq-contrasted-threshold) {
    @return $text-color;
  } @else {
    @return $color-white;
  }
}